Merged
Conversation
The two normalization branches of MixtureSampler disagreed on all-zero input: temperature == 1.0 crashed with ZeroDivisionError at the divide, temperature != 1.0 silently degraded to uniform sampling via the max(w, 1e-12) clamp. Both are reachable from the annealing phase path in scripts/train.py, where TrainingPhase.dataset_weights validates >= 0 (not > 0) to intentionally allow dropping individual datasets. A user who zeroes out every dataset in a phase transition would get a mid-run crash on one branch and silent training-quality drift on the other. Add a single _validate_weights() helper that rejects empty, negative, or all-zero weight lists with a clear ValueError, and call it from both __init__ and update_weights. The TrainingPhase schema- level validator stays permissive because it can't know the effective mixture at config-parse time; sampler-level is where the hard gate belongs.
Naeemkh
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_validate_weights(weights, context)inkempnerforge/data/sampler.py; call it from bothMixtureSampler.__init__andMixtureSampler.update_weights.ValueError. Previouslytemperature == 1.0crashed withZeroDivisionErrorat the normalization divide andtemperature != 1.0silently produced uniform sampling via themax(w, 1e-12)clamp.TrainingPhase.dataset_weightsschema validator stays>= 0so individual datasets can still be zeroed out; the sampler-level gate catches the all-zero case that the schema cannot see at config-parse time.Closes #53
Test plan
uv run pytest tests/unit/test_mixing.py::TestMixtureSamplerZeroWeights -v(8 tests).